﻿using Firestarter.DB.Schema.BO;
using FireStarterModeller.Test;
using Habanero.Testability;

namespace Firestarter.DB.Schema.Test.BO.TestUtils
{
    public class TestUtilsDBPrimaryKey
    {
        public static BOTestFactory<DBPrimaryKey> GetTestFactory()
        {
            return BOTestFactoryRegistry.Instance.Resolve<DBPrimaryKey>();
        }

        /// <summary>
        /// Creates a new saved DBPrimaryKey with a random value assigned to every property
        /// </summary>
        public static DBPrimaryKey CreateSavedDBPrimaryKey()
        {
            DBPrimaryKey dBPrimaryKey = CreateUnsavedValidDBPrimaryKey();
            dBPrimaryKey.Save();
            return dBPrimaryKey;
        }

        /// <summary>
        /// Creates a new unsaved DBPrimaryKey with a random value assigned to every property
        /// </summary>
        public static DBPrimaryKey CreateUnsavedValidDBPrimaryKey()
        {
            DBPrimaryKey dBPrimaryKey = new DBPrimaryKey();
            dBPrimaryKey.TableID = TestUtilsDBTable.CreateSavedDBTable().TableID;
//			dBPrimaryKey.PendingChangeType = null;
            dBPrimaryKey.Approved = TestUtilsShared.GetRandomBoolean();
            return dBPrimaryKey;
        }
	    
        /// <summary>
        /// Creates a new unsaved DBPrimaryKey where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static DBPrimaryKey CreateUnsavedDefaultDBPrimaryKey()
        {
            DBPrimaryKey dBPrimaryKey = new DBPrimaryKey();
            return dBPrimaryKey;
        }
    }
}